package com.zhg.controller;


import com.zhg.model.auto.Classity;
import com.zhg.service.impl.ClassityServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 达瓦里氏
 * @since 2021-12-24
 */
@RestController
@RequestMapping("/classity")
public class ClassityController {


    @Resource
    private ClassityServiceImpl classityService;

    /*查询类别*/
    @GetMapping("/getClassify")
    public List<Classity> getClassity(){ return classityService.list(); }

    /*通过id查询类别*/
    @GetMapping("/getClassifyById/{id}")
    public Classity getClassifyById(@PathVariable("id") int id){
        return classityService.getById(id);
    }

    /*修改类别*/
    @PostMapping("/updateClassify")
    public void updateClassity(@RequestBody Classity classify){ classityService.updateById(classify); }

    /*添加类别*/
    @PostMapping("/setClassify")
    public void setClassity(@RequestBody Classity classify){ classityService.save(classify); }

    /*删除类别*/
    @PostMapping("/deletedById/{id}")
    public boolean deleted(@PathVariable("id") int id){ return classityService.removeById(id); }

}
